﻿using Catalogo.Portable.Model;
using Catalogo.Portable.ViewModel.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Catalogo.Portable.ViewModel
{
    public class ViewModelBase : ModelBase
    {
        public ViewModelBase()
        {
            Subscribe();
        }

        public IMessenger Messenger
        {
            get { return Messages.Messenger.Instance; }
        }
        
        protected virtual void Subscribe() 
        { 
        }

        protected void PublishMessage<TMessage>(TMessage message)
        {
            if (Messenger != null)
                Messenger.Publish<TMessage>(message);
        }
    }
}
